package gold.digger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC552 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {

        int MOD = 1000000007;

        public int checkRecord(int n) {
            return dfs(0, n, 0, 0);
        }

        private int dfs(int day, int n, int absent, int late) {
            if (day >= n) {
                return 1;
            }

            // 回溯开始
            int ans = 0;
            // 1. Present随便放
            ans = (ans + dfs(day + 1, n, absent, 0)) % MOD;
            // 2. Absent最多只能放一个
            if (absent < 1) {
                ans = (ans + dfs(day + 1, n, 1, 0)) % MOD;
            }
            // 3. Late最多连续放2个
            if (late < 2) {
                ans = (ans + dfs(day + 1, n, absent, late + 1)) % MOD;
            }

            return ans;
        }
    }


    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC552 an = new LC552();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
